import Vue from 'vue'
import VueRouter from 'vue-router'

import Home from '../components/Home.vue'
import Movie from '../components/Movie.vue'
import About from '../components/About.vue'

// Tab组件
import Tab1 from '../components/tabs/Tab1.vue'
import Tab2 from '../components/tabs/Tab2.vue'

Vue.use(VueRouter)

const router = new VueRouter({
    routes: [
        { path: '/', redirect: '/home', },
        { path: '/home', component: Home },
        { path: '/movie', component: Movie },
        { 
            path: '/about', 
            // redirect: '/about/tab1',
            component: About, 
            children: [
                // 默认子路由：path为空字符串的子路由 称为默认子路由
                { path: '', component: Tab1 },
                { path: 'tab2', component: Tab2 }
            ] 
        }
    ]
})

router.beforeEach( (from, to, next) => {
    console.log(to)
    console.log(from)
    next()
})

export default router